package com.leesche.netdoll.communication.protocol;

public enum MessageType {

	RSP_TRANS(0x01, "01", "交易回复"), //
	RSP_START(0x02, "02", "开始游戏回复"), //
	RSP_BUTTON(0x03, "03", "按钮指令回复"), //
	RSP_ID(0x06, "06", "查询ID"), //
	STATUS(0x21, "21", "状态上报"), //
	HEARTBEAT(0x23, "23", "心跳"), //
	UNKNOWN(0x00, "00", "未知命令");

	private int code;

	private String name;

	private String desc;

	private MessageType(int code, String name, String desc) {
		this.code = code;
		this.name = name;
		this.desc = desc;
	}

	public static MessageType fromCode(int code) {

		for (MessageType type : MessageType.values()) {
			if (type.getCode() == code) {
				return type;
			}
		}

		return UNKNOWN;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

}
